import 'dart:convert' show json;

class CommonWebsiteModel {
  int errorCode;
  String errorMsg;
  List<CommonWebsiteData> data;

  CommonWebsiteModel.fromParams({this.errorCode, this.errorMsg, this.data});

  factory CommonWebsiteModel(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? CommonWebsiteModel.fromJson(json.decode(jsonStr))
          : CommonWebsiteModel.fromJson(jsonStr);

  CommonWebsiteModel.fromJson(jsonRes) {
    errorCode = jsonRes['errorCode'];
    errorMsg = jsonRes['errorMsg'];
    data = jsonRes['data'] == null ? null : data;

    for (var item in data == null ? [] : jsonRes['data']) {
      data.add(item == null ? null : CommonWebsiteData.fromJson(item));
    }
  }
}

class CommonWebsiteData {
  int id;
  int order;
  int visible;
  String icon;
  String link;
  String name;

  CommonWebsiteData.fromParams(
      {this.id, this.order, this.visible, this.icon, this.link, this.name});

  CommonWebsiteData.fromJson(jsonRes) {
    id = jsonRes['id'];
    order = jsonRes['order'];
    visible = jsonRes['visible'];
    icon = jsonRes['icon'];
    link = jsonRes['link'];
    name = jsonRes['name'];
  }

  @override
  String toString() {
    return '{"id": $id, "order": $order, "visible": $visible, "icon": ${icon == null ? 'null' : '${json.encode(icon)}'}, "link": ${link == null ? 'null' : '${json.encode(link)}'}, "name": ${name == null ? 'null' : '${json.encode(name)}'}}';
  }
}
